/**
 *  Filename: BluetoothReading.java (in org.repin.base.core.measure)
 *  This file is part of the Redpin project.
 * 
 *  Redpin is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published
 *  by the Free Software Foundation, either version 3 of the License, or
 *  any later version.
 *
 *  Redpin is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Redpin. If not, see <http://www.gnu.org/licenses/>.
 *
 *  (c) Copyright ETH Zurich, Pascal Brogle, Philipp Bolliger, 2010, ALL RIGHTS RESERVED.
 * 
 *  www.redpin.org
 */
package ch.simplix.android.net.discoverer.bluetooth;

import android.bluetooth.BluetoothDevice;



/**
 * Describes a bluetooth reading
 * 
 * @author Philipp Bolliger (philipp@bolliger.name)
 * @author Simon Tobler (simon.p.tobler@gmx.ch)
 * @author Pascal Brogle (broglep@student.ethz.ch)
 * @author Reto Koenig
 * @version 0.3
 */
public class BluetoothReading {


	/* attributes */
	protected BluetoothDevice bluetoothDevice;
	protected String friendlyName = "";
	protected String bluetoothAddress = "";
	protected String majorDeviceClass = ""; 
	protected String minorDeviceClass = "";
	protected int rssi;

	/* **************** Getter and Setter Methods **************** */

	public BluetoothDevice getBluetoothDevice() {
		return bluetoothDevice;
	}
	
	public void setBluetoothDevice(BluetoothDevice bluetoothDevice) {
		this.bluetoothDevice = bluetoothDevice;
	}
	/**
	 * @return the friendlyName
	 */
	public String getFriendlyName() {
		return friendlyName;
	}

	/**
	 * @param friendlyName
	 *            the friendlyName to set
	 */
	public void setFriendlyName(String friendlyName) {
		this.friendlyName = friendlyName;
	}

	/**
	 * @return the bluetoothAddress
	 */
	public String getBluetoothAddress() {
		return bluetoothAddress;
	}

	/**
	 * @param bluetoothAddress
	 *            the bluetoothAddress to set
	 */
	public void setBluetoothAddress(String bluetoothAddress) {
		this.bluetoothAddress = bluetoothAddress;
	}

	/**
	 * @return the majorDeviceClass
	 */
	public String getMajorDeviceClass() {
		return majorDeviceClass;
	}

	/**
	 * @param majorDeviceClass
	 *            the majorDeviceClass to set
	 */
	public void setMajorDeviceClass(String majorDeviceClass) {
		this.majorDeviceClass = majorDeviceClass;
	}

	/**
	 * @return the minorDeviceClass
	 */
	public String getMinorDeviceClass() {
		return minorDeviceClass;
	}

	/**
	 * @param minorDeviceClass
	 *            the minorDeviceClass to set
	 */
	public void setMinorDeviceClass(String minorDeviceClass) {
		this.minorDeviceClass = minorDeviceClass;
	}

	
	/*
	 * removed due to conflicts: what is id needed for?
	 *
	public String getId() {
		return bluetoothAddress;
	}
	*/
	
	
	/**
	 * Returns Bluetooth Friendly Name
	 */
	public String getHumanReadableName() {
		return friendlyName;
	}

	public void setRssi(int rssi) {
		this.rssi = rssi;
	}
	public int getRssi() {
		return rssi;
	}
	@Override
	public String toString() {
		return "BT: FRIENDLY=" + friendlyName
				+ "|rssi="+rssi+"|ADDRESS=" + bluetoothAddress +"|MAJOR=" + majorDeviceClass + "|MINOR=" + minorDeviceClass;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime
				* result
				+ ((bluetoothAddress == null) ? 0 : bluetoothAddress.hashCode());
		result = prime
				* result
				+ ((majorDeviceClass == null) ? 0 : majorDeviceClass.hashCode());
		result = prime
				* result
				+ ((minorDeviceClass == null) ? 0 : minorDeviceClass.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BluetoothReading other = (BluetoothReading) obj;
		if (bluetoothAddress == null) {
			if (other.bluetoothAddress != null)
				return false;
		} else if (!bluetoothAddress.equals(other.bluetoothAddress))
			return false;
		if (majorDeviceClass == null) {
			if (other.majorDeviceClass != null)
				return false;
		} else if (!majorDeviceClass.equals(other.majorDeviceClass))
			return false;
		if (minorDeviceClass == null) {
			if (other.minorDeviceClass != null)
				return false;
		} else if (!minorDeviceClass.equals(other.minorDeviceClass))
			return false;
		return true;
	}

	
	
}
